package sys.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sys.core.ResponseResult;
import sys.core.annotation.LoginRequired;
import sys.core.annotation.RecordLog;
import sys.entity.CustomerEntity;
import sys.entity.PageData;
import sys.entity.dto.CustomerClaimDto;
import sys.entity.dto.CustomerDto;
import sys.service.CustomerService;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/customer")
@Api(tags = "客户管理")
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    @PostMapping("/likeSelect")
    @ApiOperation(value = "查询客户信息", notes = "查询客户信息")
    @LoginRequired
    @RecordLog(value = "查询客户信息")
    public PageData<CustomerEntity> likeSelect(@RequestBody CustomerDto customerDto,HttpServletRequest request) {
        return customerService.likeSelect(customerDto,request);
    }

    @PostMapping("/claim")
    @ApiOperation(value = "认领客户", notes = "认领客户")
    @LoginRequired
    @RecordLog(value = "认领客户")
    public ResponseResult claim(@RequestBody CustomerClaimDto customerClaimDto, HttpServletRequest request) {
        return customerService.claim(customerClaimDto,request);
    }

    @GetMapping("/detail")
    @ApiOperation(value = "查看客户详情", notes = "查看客户详情")
    @LoginRequired
    @RecordLog(value = "查看客户详情")
    public ResponseResult detail(Integer customerId) {
        return customerService.detail(customerId);
    }











}
